digits :: Integer -> [Integer]
digits a
	| a < 10 = [a]
	| otherwise = (a `mod` 10) : digits (a `div` 10)

factorial :: Integer -> Integer
factorial 0 = 1
factorial n = foldr1 (*) [1..n]

sumOfDigitFactorials :: Integer -> Integer
sumOfDigitFactorials n = sum $ map factorial (digits n)

euler_034 = sum [x | x<-[3..((factorial 9) * 7)], x == sumOfDigitFactorials x] 
